<?xml version="1.0"?>
<!--
  ~ Copyright 2004-2012 ICEsoft Technologies Canada Corp.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the
  ~ License. You may obtain a copy of the License at
  ~
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing,
  ~ software distributed under the License is distributed on an "AS
  ~ IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  ~ express or implied. See the License for the specific language
  ~ governing permissions and limitations under the License.
  -->

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ace="http://www.icefaces.org/icefaces/components"
    xmlns:ice="http://www.icesoft.com/icefaces/component"
    xmlns:icecore="http://www.icefaces.org/icefaces/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/resources/templates/content-template.xhtml">

    <ui:param name="title" value="#{msgs[progressBarPush.title]}"/>
    <ui:param name="description" value="#{msgs[progressBarPush.description]}"/>
    <ui:param name="resourceValue" value="#{progressBarPush.exampleResource}"/>
    
    <ui:param name="wikiResources" value="#{progressBarResources.wikiResources}"/>
    <ui:param name="tldResources" value="#{progressBarResources.tldResources}"/>

    <ui:define name="example">
        <h:form id="form">
            <ace:panel> 
                <h:panelGrid width="100%" style="text-align: center;" columns="1">
                    <h:panelGrid columns="2" styleClass="centeredPanelGrid">
                        <h:outputText value="Progress "/>
                        <h:outputText id="progress" value="@ #{task.progress} %" rendered="#{task.progress ne 100 and task.taskRunning}" style="font-weight: bold;"/>    
                        <h:outputText id="completed" value="completed" rendered="#{task.progress eq 100}" style="font-weight: bold;"/>
                        <h:outputText id="paused" value="paused" rendered="#{(task.progress gt 0 and task.progress lt 100) and !task.taskRunning}" style="font-weight: bold;"/>
                        <h:outputText id="stopped" value="stopped" rendered="#{(task.progress eq 0) and !task.taskRunning}" style="font-weight: bold;"/>
                    </h:panelGrid>
                    
                    <ace:progressBar   id="myProgressBar"
                                       value="#{task.progress}"/>
                    
                    
                    <h:panelGrid columns="2" style="text-align: center; margin-left: auto; margin-right: auto; width: 150px; height: 50px;">                                
                        <h:commandLink  id="start"
										actionListener="#{progressBarPush.startTask}"
										rendered="#{!task.taskRunning}"
										disabled="#{task.taskRunning}">
                            <h:graphicImage id="playImg" value="#{progressBarPush.playImage.path}" alt="#{progressBarPush.playImage.description}"/>
                        </h:commandLink>
                        <h:commandLink id="reset"
									   actionListener="#{task.resetTask}"
									   rendered="#{!task.taskRunning}"
									   disabled="#{task.taskRunning}">
                            <h:graphicImage id="stopImg" value="#{progressBarPush.stopImage.path}" alt="#{progressBarPush.stopImage.description}"/>
                        </h:commandLink>
                        <h:commandLink id="stop"
									   actionListener="#{task.stopTask}"
                                       rendered="#{task.taskRunning}"
                                       disabled="#{!task.taskRunning}">
                            <h:graphicImage id="pauseImg" value="#{progressBarPush.pauseImage.path}" alt="#{progressBarPush.pauseImage.description}"/>
                        </h:commandLink>
                    
                   </h:panelGrid>
                </h:panelGrid>
            </ace:panel>
            
            <ui:remove>
                <ace:panel>
                    <h:dataTable id="messages" var="message" value="#{pushManagementBean.messages}" width="100%" style="text-align: center;">
                        <h:column>
                            <f:facet name="header">
                                Session ID
                            </f:facet>
                            <h:outputText value="#{message.id}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                Message
                            </f:facet>
                            <h:outputText id="desc" value="#{message.description}"/>
                        </h:column>
                    </h:dataTable>
                </ace:panel>
            </ui:remove>
        </h:form>
    </ui:define>
</ui:composition>
